package com.zmn.plat.admin.controller.servcategory;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.common.dictionary.GlobalDict;
import com.zmn.plat.model.entity.servcategory.ServCategory;
import com.zmn.plat.model.entity.servcategory.ServCategoryQuery;

/**
 * 类描述:前台服务分类控制器
 * 
 * @author linfeng
 * @version v1.0
 * @since 2019/09/20 9:15
 */
@Controller
@RequestMapping("/serv/showCateg/")
public class ShowServCategoryListController extends ServCategoryBaseController {
    private Logger logger = LoggerFactory.getLogger(ShowServCategoryListController.class);

    @RequestMapping(value = "list")
    public ModelAndView list(@ModelAttribute ServCategoryQuery query) {
        List<ServCategory> items = servCategoryService.listShowPageByQuery(query);

        ModelAndView mav = new ModelAndView("servcategroy/show/list");

        mav.addObject("vo", query);
        mav.addObject("items", items);
        return mav;
    }

    @RequestMapping(value = "detail")
    public ModelAndView detail(@RequestParam(value = "categId", defaultValue = "0") Integer categId) {
        ServCategory categ;
        if (categId > 0) {
            categ = servCategoryService.findByKey(categId);
        } else {
            categ = new ServCategory();
        }

        ModelAndView mav = new ModelAndView("servcategroy/show/detail");

        mav.addObject("statuses", GlobalDict.getStatusList(false));
        mav.addObject("vo", categId);
        mav.addObject("categ", categ);
        mav.addObject("servCategory", categ);
        mav.addObject("flag", 1);
        return mav;
    }
}
